<template>
  <div>
    <van-picker
      title="标题"
      show-toolbar
      :columns="columns"
      @confirm="onConfirm"
      @cancel="onCancel"
      @change="onChange"
    />
  </div>
</template>
<script>
import { editUserinfo_api } from "@/api/user.js";
export default {
  data() {
    return {
      //   显示性别数据
      columns: ["男", "女"],
    };
  },
  methods: {
    async onConfirm(value, index) {
      const { data: res } = await editUserinfo_api({ gender: index });
      console.log(res);
      //   res.data.gender
      this.$toast(`当前值：${value}, 当前索引：${index}`);
      this.$emit("genderfunc", res.data.gender);
    },
    onChange(picker, value, index) {
      this.$toast(`当前值：${value}, 当前索引：${index}`, picker);
    },
    onCancel() {
      this.$emit("genderfunc");
    },
  },
};
</script>
<style lang='less' scoped>
</style>